package cn.maiyar.redis.properties;

import cn.maiyar.redis.enums.LockType;
import cn.maiyar.redis.enums.Pattern;
import lombok.Getter;
import lombok.Setter;
import org.redisson.config.SslProvider;
import org.redisson.config.TransportMode;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.net.URL;

/**
 * Redisson配置
 *
 * @author c.c
 **/
@Getter
@Setter
//@ConfigurationProperties(prefix = "redisson")
public class RedissonProperties {

    private Pattern model = Pattern.SINGLE;
    private String codec = "org.redisson.codec.JsonJacksonCodec";
    private Integer threads;
    private Integer nettyThreads;
    private TransportMode transportMode = TransportMode.NIO;

    //公共参数
    private Integer idleConnectionTimeout = 10000;
    private Integer connectTimeout = 10000;
    private Integer timeout = 3000;
    private Integer retryAttempts = 3;
    private Integer retryInterval = 1500;
    private String password;
    private Integer subscriptionsPerConnection = 5;
    private String clientName;
    private Boolean sslEnableEndpointIdentification = true;
    private SslProvider sslProvider = SslProvider.JDK;
    private URL sslTruststore;
    private String sslTruststorePassword;
    private URL sslKeystore;
    private String sslKeystorePassword;
    private Integer pingConnectionInterval = 1000;
    private Boolean keepAlive = false;
    private Boolean tcpNoDelay = false;
    private Boolean referenceEnabled = true;
    private Long lockWatchdogTimeout = 30000L;
    private Boolean keepPubSubOrder = true;
    private Boolean decodeInExecutor = false;
    private Boolean useScriptCache = false;
    private Integer minCleanUpDelay = 5;
    private Integer maxCleanUpDelay = 1800;
    // 锁的模式 如果不设置 单个key默认可重入锁 多个key默认联锁
    private LockType lockModel;
    //等待加锁超时时间 -1一直等待
    private Long attemptTimeout = 10000L;
    //数据缓存时间 默认30分钟
    private Long dataValidTime = 1000 * 60 * 30L;
    //结束
    @NestedConfigurationProperty
    private SingleServerConfig singleServerConfig;
    @NestedConfigurationProperty
    private MultipleServerConfig multipleServerConfig;
}
